TypeErrorTraceback (most recent call last)
<ipython-input-130-b72a54751bac> in <module>
----> 1 for x in DataLoader(source,bs=1,n=20):print(x)
/opt/conda/lib/python3.8/site-packages/fastai/data/load.py in __iter__(self)
107 self.before_iter()
108 self.__idxs=self.get_idxs() # called in context of main process (not workers/subprocesses)
--> 109 for b in _loaders[self.fake_l.num_workers==0](self.fake_l):
110 if self.device is not None: b = to_device(b, self.device)
111 yield self.after_batch(b)
/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py in __next__(self)
515 if self._sampler_iter is None:
516 self._reset()
--> 517 data = self._next_data()
518 self._num_yielded += 1
519 if self._dataset_kind == _DatasetKind.Iterable and \
/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py in _next_data(self)
555 def _next_data(self):
556 index = self._next_index() # may raise StopIteration
--> 557 data = self._dataset_fetcher.fetch(index) # may raise StopIteration
558 if self._pin_memory:
559 data = _utils.pin_memory.pin_memory(data)
/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py in fetch(self, possibly_batched_index)
32 raise StopIteration
33 else:
---> 34 data = next(self.dataset_iter)
35 return self.collate_fn(data)
36
/opt/conda/lib/python3.8/site-packages/fastai/data/load.py in create_batches(self, samps)
116 if self.dataset is not None: self.it = iter(self.dataset)
117 res = filter(lambda o:o is not None, map(self.do_item, samps))
--> 118 yield from map(self.do_batch, self.chunkify(res))
119
120 def new(self, dataset=None, cls=None, **kwargs):
/opt/conda/lib/python3.8/site-packages/fastcore/basics.py in chunked(it, chunk_sz, drop_last, n_chunks)
214 if not isinstance(it, Iterator): it = iter(it)
215 while True:
--> 216 res = list(itertools.islice(it, chunk_sz))
217 if res and (len(res)==chunk_sz or not drop_last): yield res
218 if len(res)<chunk_sz: return
/opt/conda/lib/python3.8/site-packages/fastai/data/load.py in do_item(self, s)
131 def prebatched(self): return self.bs is None
132 def do_item(self, s):
--> 133 try: return self.after_item(self.create_item(s))
134 except SkipItemException: return None
135 def chunkify(self, b): return b if self.prebatched else chunked(b, self.bs, self.drop_last)
/opt/conda/lib/python3.8/site-packages/fastai/data/load.py in create_item(self, s)
139 def create_item(self, s):
140 if self.indexed: return self.dataset[s or 0]
--> 141 elif s is None: return next(self.it)
142 else: raise IndexError("Cannot index an iterable dataset numerically - must use `None`.")
143 def create_batch(self, b): return (fa_collate,fa_convert)[self.prebatched](b)
~/fastrl/fastrl/data/block.py in __iter__(self)
119 self('before_episodes')
120 while True:
--> 121 self._with_events(self._do_reset,'reset',Exception)
122 self._with_events(self._do_action,'do_action',Exception)
123 self._with_events(self._do_step,'do_step',Exception)
~/fastrl/fastrl/callback/core.py in _with_events(self, f, event_type, ex, final)
59 def _with_events(self, f, event_type, ex, final=noop):
60 try: self(f'before_{event_type}'); f()
---> 61 except ex: self(f'after_cancel_{event_type}')
62 self(f'after_{event_type}'); final()
63
~/fastrl/fastrl/callback/core.py in __call__(self, event_name)
75
76 def ordered_cbs(self, event): return [cb for cb in self.cbs.sorted('order') if hasattr(cb, event)]
---> 77 def __call__(self, event_name): L(event_name).map(self._call_one)
78
79 def _call_one(self, event_name):
/opt/conda/lib/python3.8/site-packages/fastcore/foundation.py in map(self, f, gen, *args, **kwargs)
152 def range(cls, a, b=None, step=None): return cls(range_of(a, b=b, step=step))
153
--> 154 def map(self, f, *args, gen=False, **kwargs): return self._new(map_ex(self, f, *args, gen=gen, **kwargs))
155 def argwhere(self, f, negate=False, **kwargs): return self._new(argwhere(self, f, negate, **kwargs))
156 def filter(self, f=noop, negate=False, gen=False, **kwargs):
/opt/conda/lib/python3.8/site-packages/fastcore/basics.py in map_ex(iterable, f, gen, *args, **kwargs)
664 res = map(g, iterable)
665 if gen: return res
--> 666 return list(res)
667
668 # Cell
/opt/conda/lib/python3.8/site-packages/fastcore/basics.py in __call__(self, *args, **kwargs)
649 if isinstance(v,_Arg): kwargs[k] = args.pop(v.i)
650 fargs = [args[x.i] if isinstance(x, _Arg) else x for x in self.pargs] + args[self.maxi+1:]
--> 651 return self.func(*fargs, **kwargs)
652
653 # Cell
~/fastrl/fastrl/callback/core.py in _call_one(self, event_name)
79 def _call_one(self, event_name):
80 if not hasattr(self._events, event_name): raise Exception(f'missing {event_name}')
---> 81 for cb in self.cbs.sorted('order'): cb(event_name)
82
83
~/fastrl/fastrl/callback/core.py in __call__(self, event_name, **kwargs)
117 res=None
118 if self.run and _run:
--> 119 res=getattr(self, event_name, noop)(**kwargs)
120 if event_name==self.end_event: self.run=True #Reset self.run to True at each end of fit
121 return res
~/fastrl/fastrl/callback/core.py in _with_events(self, f, event_type, ex, final)
58
59 def _with_events(self, f, event_type, ex, final=noop):
---> 60 try: self(f'before_{event_type}'); f()
61 except ex: self(f'after_cancel_{event_type}')
62 self(f'after_{event_type}'); final()
~/fastrl/fastrl/data/block.py in _do_reset(self)
86
87 def _init_state(self): self('initialize')
---> 88 def _do_reset(self): self('reset')
89 def _do_action(self): self('do_action')
90 def _do_step(self): self('do_step')
~/fastrl/fastrl/callback/core.py in __call__(self, event_name)
75
76 def ordered_cbs(self, event): return [cb for cb in self.cbs.sorted('order') if hasattr(cb, event)]
---> 77 def __call__(self, event_name): L(event_name).map(self._call_one)
78
79 def _call_one(self, event_name):
/opt/conda/lib/python3.8/site-packages/fastcore/foundation.py in map(self, f, gen, *args, **kwargs)
152 def range(cls, a, b=None, step=None): return cls(range_of(a, b=b, step=step))
153
--> 154 def map(self, f, *args, gen=False, **kwargs): return self._new(map_ex(self, f, *args, gen=gen, **kwargs))
155 def argwhere(self, f, negate=False, **kwargs): return self._new(argwhere(self, f, negate, **kwargs))
156 def filter(self, f=noop, negate=False, gen=False, **kwargs):
/opt/conda/lib/python3.8/site-packages/fastcore/basics.py in map_ex(iterable, f, gen, *args, **kwargs)
664 res = map(g, iterable)
665 if gen: return res
--> 666 return list(res)
667
668 # Cell
/opt/conda/lib/python3.8/site-packages/fastcore/basics.py in __call__(self, *args, **kwargs)
649 if isinstance(v,_Arg): kwargs[k] = args.pop(v.i)
650 fargs = [args[x.i] if isinstance(x, _Arg) else x for x in self.pargs] + args[self.maxi+1:]
--> 651 return self.func(*fargs, **kwargs)
652
653 # Cell
~/fastrl/fastrl/callback/core.py in _call_one(self, event_name)
79 def _call_one(self, event_name):
80 if not hasattr(self._events, event_name): raise Exception(f'missing {event_name}')
---> 81 for cb in self.cbs.sorted('order'): cb(event_name)
82
83
~/fastrl/fastrl/callback/core.py in __call__(self, event_name, **kwargs)
117 res=None
118 if self.run and _run:
--> 119 res=getattr(self, event_name, noop)(**kwargs)
120 if event_name==self.end_event: self.run=True #Reset self.run to True at each end of fit
121 return res
~/fastrl/fastrl/data/block.py in reset(self)
222 if self.imask.sum()==0:
223 _shape_map={k:v for k,v in self.shape_map.items() if k!='episode_num'}
--> 224 reset_exps=D(_shape_map).mapv(_batchwise_zero,bs=self.n_envs)
225 for k,v in reset_exps.items(): setattr(self.source,k,v)
226 self.source.pool.map(_env_seed,seed=self.seed)
~/fastrl/fastrl/core.py in mapv(self, f, gen, wise, *args, **kwargs)
45 return self.map(f,*args,gen=gen,wise=wise,**kwargs)
46 def mapv(self,f,*args,gen=False,wise='value',**kwargs):
---> 47 return self.map(f,*args,gen=gen,wise=wise,**kwargs)
48
49 # Cell
~/fastrl/fastrl/core.py in map(self, f, gen, *args, **kwargs)
41
42 def map(self,f,*args,gen=False,**kwargs):
---> 43 return (self._new,noop)[gen](map_dict_ex(self,f,*args,**kwargs),mapping=True)
44 def mapk(self,f,*args,gen=False,wise='key',**kwargs):
45 return self.map(f,*args,gen=gen,wise=wise,**kwargs)
~/fastrl/fastrl/core.py in _new(self, *args, **kwargs)
38 if with_diff: return eq,set(o.keys()).symmetric_difference(set(self.keys()))
39 return eq
---> 40 def _new(self,*args,**kwargs): return type(self)(*args,**kwargs)
41
42 def map(self,f,*args,gen=False,**kwargs):
~/fastrl/fastrl/core.py in __init__(self, mapping, *args, **kwargs)
32 def __init__(self,*args,mapping=False,**kwargs):
33 self.mapping=mapping
---> 34 super().__init__(*args,**kwargs)
35
36 def eq_k(self,o:'D',with_diff=False):
~/fastrl/fastrl/core.py in <genexpr>(.0)
23
24 if wise is None: return map(g,d.items())
---> 25 return ((k,g(v)) if wise=='value' else (g(k),v) for k,v in d.items())
26
27 # Cell
/opt/conda/lib/python3.8/site-packages/fastcore/basics.py in __call__(self, *args, **kwargs)
649 if isinstance(v,_Arg): kwargs[k] = args.pop(v.i)
650 fargs = [args[x.i] if isinstance(x, _Arg) else x for x in self.pargs] + args[self.maxi+1:]
--> 651 return self.func(*fargs, **kwargs)
652
653 # Cell
~/fastrl/fastrl/data/block.py in _batchwise_zero(shape, bs)
179 return (s,r,d,info)
180
--> 181 def _batchwise_zero(shape,bs): return torch.zeros((bs,*shape[1:]))
182
183 class GymSrc(SrcCallback):
TypeError: zeros(): argument 'size' must be tuple of ints, but found element of type numpy.float32 at pos 2